﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UniRlv.Utility.AppLib
{
    public abstract class AbtDODevice
    {
        public abstract bool Open();
        public abstract bool IsOpen();
        public abstract void Close();
        public abstract void Pause();
        public abstract void Resume();
        public abstract void SendData(byte[] bytes, int len);
        public abstract void OutPut(int pin);

        protected string _initString;
        public abstract string InitString { get; set; }
        public string ErrorString { get; set; }

        public virtual void SendData(string s)
        {
            byte[] bytes = Encoding.GetEncoding("GBK").GetBytes(s);
            SendData(bytes, bytes.Length);
        }

        public virtual void Alarm(int nStation, object obj)
        {//1 3 5 7
            OutPut((nStation-1)*2+1);
        }

        public virtual void Pick(int nStation, object obj)
        {//0 2 4 6
            OutPut((nStation - 1) * 2);
        }

        public virtual void Flip(int nStation, object obj)
        {
            OutPut(4);
        }

        public virtual void Stop(int nStation, object obj)
        {
            OutPut(5);
        }
    }
}
